package com.gruopbuying.agent.service.impl;


import com.gruopbuying.agent.constants.AgentAuditStoreEnumConstants;
import com.gruopbuying.agent.dao.AgentAuditStoreDao;
import com.gruopbuying.agent.domain.AgentAuditStoreDO;
import com.gruopbuying.agent.service.AgentAuditStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AgentAuditStoreServiceImpl implements AgentAuditStoreService {

	@Autowired
	AgentAuditStoreDao agentAuditStoreDao;

	@Override
	public List<AgentAuditStoreDO> list(Map<String, Object> map){
		List<AgentAuditStoreDO> agentAuditStores = agentAuditStoreDao.list(map);
		for(AgentAuditStoreDO store: agentAuditStores){
			String status = store.getStatus();
			if(AgentAuditStoreEnumConstants.ENUM_STATUS_DISABLE.equals(status)){
				store.setStatus("禁用");
			}else if(AgentAuditStoreEnumConstants.ENUM_STATUS_NORMAL.equals(status)){
				store.setStatus("审核通过");
			}else if(AgentAuditStoreEnumConstants.ENUM_STATUS_AUDITTING.equals(status)){
				store.setStatus("待审核");
			}else if(AgentAuditStoreEnumConstants.ENUM_STATUS_REJECTED.equals(status)){
				store.setStatus("审核驳回");
			}
			String address = store.getProvince() + " " +store.getCity();
			store.setAddress(address);
		}
		return agentAuditStores;
	}

	@Override
	public int count(Map<String, Object> map){return agentAuditStoreDao.count(map);}
}
